<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>USBGUARD项目编译环境配置 | ShuangChenYue</title>
    <meta name="generator" content="VuePress 1.9.10">
    <link rel="icon" href="https://cdn.jsdelivr.net/gh/cmty256/imgs-blog@main/logo/白云.38zbldnhh180.jpg">
    <meta name="description" content="满招损，谦受益">
    <meta name="keywords" content="专注于Cpp语言的旅行者">
    
    <link rel="preload" href="/assets/css/0.styles.952d6952.css" as="style"><link rel="preload" href="/assets/js/app.67adcfd9.js" as="script"><link rel="preload" href="/assets/js/4.9aaa1650.js" as="script"><link rel="preload" href="/assets/js/1.5474518c.js" as="script"><link rel="preload" href="/assets/js/3.593d14fc.js" as="script"><link rel="preload" href="/assets/js/160.f8624459.js" as="script"><link rel="prefetch" href="/assets/js/10.3242746b.js"><link rel="prefetch" href="/assets/js/100.9224de43.js"><link rel="prefetch" href="/assets/js/101.f0d1b059.js"><link rel="prefetch" href="/assets/js/102.996bfc6d.js"><link rel="prefetch" href="/assets/js/103.9bfdbd6f.js"><link rel="prefetch" href="/assets/js/104.8613f283.js"><link rel="prefetch" href="/assets/js/105.aa6e809e.js"><link rel="prefetch" href="/assets/js/106.90192392.js"><link rel="prefetch" href="/assets/js/107.e82a40b7.js"><link rel="prefetch" href="/assets/js/108.994cd438.js"><link rel="prefetch" href="/assets/js/109.ec15acc2.js"><link rel="prefetch" href="/assets/js/11.c04b41c1.js"><link rel="prefetch" href="/assets/js/110.c32d8576.js"><link rel="prefetch" href="/assets/js/111.453b5d50.js"><link rel="prefetch" href="/assets/js/112.ffbdb3a4.js"><link rel="prefetch" href="/assets/js/113.12b8ad7d.js"><link rel="prefetch" href="/assets/js/114.899d2998.js"><link rel="prefetch" href="/assets/js/115.b7ad9576.js"><link rel="prefetch" href="/assets/js/116.a8394748.js"><link rel="prefetch" href="/assets/js/117.0edfe25b.js"><link rel="prefetch" href="/assets/js/118.9161b1fe.js"><link rel="prefetch" href="/assets/js/119.be59e21b.js"><link rel="prefetch" href="/assets/js/12.41437bf6.js"><link rel="prefetch" href="/assets/js/120.bcf439fb.js"><link rel="prefetch" href="/assets/js/121.c3d251b8.js"><link rel="prefetch" href="/assets/js/122.62b1caba.js"><link rel="prefetch" href="/assets/js/123.787c2ab0.js"><link rel="prefetch" href="/assets/js/124.a880746f.js"><link rel="prefetch" href="/assets/js/125.d8edfe7b.js"><link rel="prefetch" href="/assets/js/126.4ff01546.js"><link rel="prefetch" href="/assets/js/127.9416d1ff.js"><link rel="prefetch" href="/assets/js/128.01a4a7a0.js"><link rel="prefetch" href="/assets/js/129.76876665.js"><link rel="prefetch" href="/assets/js/13.922328e9.js"><link rel="prefetch" href="/assets/js/130.7f631dd9.js"><link rel="prefetch" href="/assets/js/131.c9e0fde9.js"><link rel="prefetch" href="/assets/js/132.1c04cde5.js"><link rel="prefetch" href="/assets/js/133.e8f381cd.js"><link rel="prefetch" href="/assets/js/134.03d19f8b.js"><link rel="prefetch" href="/assets/js/135.44607494.js"><link rel="prefetch" href="/assets/js/136.6a1eb3c9.js"><link rel="prefetch" href="/assets/js/137.27898fd1.js"><link rel="prefetch" href="/assets/js/138.5bc0cf54.js"><link rel="prefetch" href="/assets/js/139.c2d1addc.js"><link rel="prefetch" href="/assets/js/14.e54d7526.js"><link rel="prefetch" href="/assets/js/140.052ec8e4.js"><link rel="prefetch" href="/assets/js/141.131abb5a.js"><link rel="prefetch" href="/assets/js/142.6ba6c07b.js"><link rel="prefetch" href="/assets/js/143.5dd51d22.js"><link rel="prefetch" href="/assets/js/144.b45afca8.js"><link rel="prefetch" href="/assets/js/145.faa9fb04.js"><link rel="prefetch" href="/assets/js/146.b54c024d.js"><link rel="prefetch" href="/assets/js/147.a1223242.js"><link rel="prefetch" href="/assets/js/148.4767bcb2.js"><link rel="prefetch" href="/assets/js/149.b65ab046.js"><link rel="prefetch" href="/assets/js/15.7082a3da.js"><link rel="prefetch" href="/assets/js/150.9bd8c175.js"><link rel="prefetch" href="/assets/js/151.9f830e96.js"><link rel="prefetch" href="/assets/js/152.41cde7f0.js"><link rel="prefetch" href="/assets/js/153.f57d65e0.js"><link rel="prefetch" href="/assets/js/154.5d7c8d51.js"><link rel="prefetch" href="/assets/js/155.0ae99532.js"><link rel="prefetch" href="/assets/js/156.5a54e043.js"><link rel="prefetch" href="/assets/js/157.c25b5d40.js"><link rel="prefetch" href="/assets/js/158.aa025b46.js"><link rel="prefetch" href="/assets/js/159.47939d88.js"><link rel="prefetch" href="/assets/js/16.fc775b7b.js"><link rel="prefetch" href="/assets/js/161.7a075dc2.js"><link rel="prefetch" href="/assets/js/162.1d48f266.js"><link rel="prefetch" href="/assets/js/163.5d68a99f.js"><link rel="prefetch" href="/assets/js/164.1262d0e5.js"><link rel="prefetch" href="/assets/js/165.2ccf0bdd.js"><link rel="prefetch" href="/assets/js/166.21ece4d9.js"><link rel="prefetch" href="/assets/js/167.bf8adb95.js"><link rel="prefetch" href="/assets/js/168.1cb8440d.js"><link rel="prefetch" href="/assets/js/169.1dd1e396.js"><link rel="prefetch" href="/assets/js/17.ecc7be70.js"><link rel="prefetch" href="/assets/js/170.c29ec18f.js"><link rel="prefetch" href="/assets/js/171.38820827.js"><link rel="prefetch" href="/assets/js/172.bbc8ffc6.js"><link rel="prefetch" href="/assets/js/173.470e21e7.js"><link rel="prefetch" href="/assets/js/174.3c2df318.js"><link rel="prefetch" href="/assets/js/175.d2690cdb.js"><link rel="prefetch" href="/assets/js/176.9ca64696.js"><link rel="prefetch" href="/assets/js/177.76f3271d.js"><link rel="prefetch" href="/assets/js/178.d7d9def2.js"><link rel="prefetch" href="/assets/js/179.b5644743.js"><link rel="prefetch" href="/assets/js/18.31fe7ecd.js"><link rel="prefetch" href="/assets/js/180.7592d5ef.js"><link rel="prefetch" href="/assets/js/181.5cb77d35.js"><link rel="prefetch" href="/assets/js/182.6fa5633c.js"><link rel="prefetch" href="/assets/js/183.b3a53d1b.js"><link rel="prefetch" href="/assets/js/184.3815c537.js"><link rel="prefetch" href="/assets/js/185.bcf4ab71.js"><link rel="prefetch" href="/assets/js/186.1cc02f6d.js"><link rel="prefetch" href="/assets/js/187.8b425fb7.js"><link rel="prefetch" href="/assets/js/188.44ccbd02.js"><link rel="prefetch" href="/assets/js/189.353b35e3.js"><link rel="prefetch" href="/assets/js/19.520992d5.js"><link rel="prefetch" href="/assets/js/190.c284595f.js"><link rel="prefetch" href="/assets/js/191.788ecc2d.js"><link rel="prefetch" href="/assets/js/192.712a164e.js"><link rel="prefetch" href="/assets/js/193.da58aba3.js"><link rel="prefetch" href="/assets/js/194.6b1b1f4d.js"><link rel="prefetch" href="/assets/js/195.c31d5c39.js"><link rel="prefetch" href="/assets/js/196.f6670c4d.js"><link rel="prefetch" href="/assets/js/197.5a1f50ab.js"><link rel="prefetch" href="/assets/js/2.ab565158.js"><link rel="prefetch" href="/assets/js/20.69e29cdc.js"><link rel="prefetch" href="/assets/js/21.2fd424ad.js"><link rel="prefetch" href="/assets/js/22.d4c0be54.js"><link rel="prefetch" href="/assets/js/23.4bb90ecc.js"><link rel="prefetch" href="/assets/js/24.c01be6b2.js"><link rel="prefetch" href="/assets/js/25.c8833687.js"><link rel="prefetch" href="/assets/js/26.8042b555.js"><link rel="prefetch" href="/assets/js/27.0d5fa4c0.js"><link rel="prefetch" href="/assets/js/28.f9735b8b.js"><link rel="prefetch" href="/assets/js/29.3af53626.js"><link rel="prefetch" href="/assets/js/30.5f1b56d1.js"><link rel="prefetch" href="/assets/js/31.544b2649.js"><link rel="prefetch" href="/assets/js/32.aa321988.js"><link rel="prefetch" href="/assets/js/33.6aba2c86.js"><link rel="prefetch" href="/assets/js/34.e1bbff24.js"><link rel="prefetch" href="/assets/js/35.233f76e0.js"><link rel="prefetch" href="/assets/js/36.cb773972.js"><link rel="prefetch" href="/assets/js/37.393d9c59.js"><link rel="prefetch" href="/assets/js/38.e2d530c5.js"><link rel="prefetch" href="/assets/js/39.acaf1cc0.js"><link rel="prefetch" href="/assets/js/40.358f731e.js"><link rel="prefetch" href="/assets/js/41.ded24b7e.js"><link rel="prefetch" href="/assets/js/42.b9f683c3.js"><link rel="prefetch" href="/assets/js/43.c8fb3e66.js"><link rel="prefetch" href="/assets/js/44.633142da.js"><link rel="prefetch" href="/assets/js/45.6095e772.js"><link rel="prefetch" href="/assets/js/46.421d8c7a.js"><link rel="prefetch" href="/assets/js/47.da50fe47.js"><link rel="prefetch" href="/assets/js/48.15ff5726.js"><link rel="prefetch" href="/assets/js/49.b662e624.js"><link rel="prefetch" href="/assets/js/5.c1b8a209.js"><link rel="prefetch" href="/assets/js/50.a8bc75df.js"><link rel="prefetch" href="/assets/js/51.51e36ae7.js"><link rel="prefetch" href="/assets/js/52.54cc6e51.js"><link rel="prefetch" href="/assets/js/53.4173561d.js"><link rel="prefetch" href="/assets/js/54.7cab8416.js"><link rel="prefetch" href="/assets/js/55.3d7317d3.js"><link rel="prefetch" href="/assets/js/56.3c22255b.js"><link rel="prefetch" href="/assets/js/57.18e46e30.js"><link rel="prefetch" href="/assets/js/58.aad57f31.js"><link rel="prefetch" href="/assets/js/59.7897f6a7.js"><link rel="prefetch" href="/assets/js/6.3131f88a.js"><link rel="prefetch" href="/assets/js/60.5cd0051a.js"><link rel="prefetch" href="/assets/js/61.d9606403.js"><link rel="prefetch" href="/assets/js/62.aede9df0.js"><link rel="prefetch" href="/assets/js/63.2c30e554.js"><link rel="prefetch" href="/assets/js/64.18228ab7.js"><link rel="prefetch" href="/assets/js/65.27cb3fba.js"><link rel="prefetch" href="/assets/js/66.2fa6c2dc.js"><link rel="prefetch" href="/assets/js/67.d274a8df.js"><link rel="prefetch" href="/assets/js/68.3069cfcf.js"><link rel="prefetch" href="/assets/js/69.4c28600f.js"><link rel="prefetch" href="/assets/js/7.89e6165d.js"><link rel="prefetch" href="/assets/js/70.4175440c.js"><link rel="prefetch" href="/assets/js/71.2ee6b435.js"><link rel="prefetch" href="/assets/js/72.c75e3bb8.js"><link rel="prefetch" href="/assets/js/73.6f8b8211.js"><link rel="prefetch" href="/assets/js/74.6c7720cf.js"><link rel="prefetch" href="/assets/js/75.cccfb229.js"><link rel="prefetch" href="/assets/js/76.f022e5da.js"><link rel="prefetch" href="/assets/js/77.dab46206.js"><link rel="prefetch" href="/assets/js/78.ca574b2a.js"><link rel="prefetch" href="/assets/js/79.3d75e618.js"><link rel="prefetch" href="/assets/js/80.091749b1.js"><link rel="prefetch" href="/assets/js/81.14db0e21.js"><link rel="prefetch" href="/assets/js/82.8a2b1809.js"><link rel="prefetch" href="/assets/js/83.84a4b599.js"><link rel="prefetch" href="/assets/js/84.11d7c222.js"><link rel="prefetch" href="/assets/js/85.273d4388.js"><link rel="prefetch" href="/assets/js/86.fb40e20c.js"><link rel="prefetch" href="/assets/js/87.3316639e.js"><link rel="prefetch" href="/assets/js/88.dfc52200.js"><link rel="prefetch" href="/assets/js/89.8d615f6e.js"><link rel="prefetch" href="/assets/js/90.1d9f08bb.js"><link rel="prefetch" href="/assets/js/91.566813e7.js"><link rel="prefetch" href="/assets/js/92.d13c6f41.js"><link rel="prefetch" href="/assets/js/93.845c42a0.js"><link rel="prefetch" href="/assets/js/94.20a37b77.js"><link rel="prefetch" href="/assets/js/95.1a498005.js"><link rel="prefetch" href="/assets/js/96.39fa7f4b.js"><link rel="prefetch" href="/assets/js/97.50f7170e.js"><link rel="prefetch" href="/assets/js/98.dd2e15d6.js"><link rel="prefetch" href="/assets/js/99.ef7ea06a.js"><link rel="prefetch" href="/assets/js/vendors~docsearch.ae6b1de9.js">
    <link rel="stylesheet" href="/assets/css/0.styles.952d6952.css">
  </head>
  <body class="theme-mode-light">
    <div id="app" data-server-rendered="true"><div class="theme-container sidebar-open have-rightmenu"><header class="navbar blur"><div title="目录" class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="https://cdn.jsdelivr.net/gh/cmty256/imgs-blog@main/logo/白云.38zbldnhh180.jpg" alt="ShuangChenYue" class="logo"> <span class="site-name can-hide">ShuangChenYue</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="CPP语言" class="dropdown-title"><!----> <span class="title" style="display:;">CPP语言</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/c5bdd8/" class="nav-link">Cpp之旅</a></li><li class="dropdown-item"><!----> <a href="/pages/279e62/" class="nav-link">Cpp专栏</a></li><li class="dropdown-item"><!----> <a href="/pages/801755/" class="nav-link">Effective_CPP</a></li><li class="dropdown-item"><!----> <a href="/pages/6b2468/" class="nav-link">muduo网络库</a></li><li class="dropdown-item"><!----> <a href="/pages/5f8c9f/" class="nav-link">Unix环境高级编程</a></li><li class="dropdown-item"><!----> <a href="/pages/3f1d21/" class="nav-link">Cpp提高编程</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="计算机基础" class="dropdown-title"><!----> <span class="title" style="display:;">计算机基础</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/7b1cb2/" class="nav-link">计算机网络</a></li><li class="dropdown-item"><!----> <a href="/pages/6048a8/" class="nav-link">操作系统</a></li><li class="dropdown-item"><!----> <a href="/pages/3b34ba/" class="nav-link">数据结构</a></li><li class="dropdown-item"><!----> <a href="/pages/412fe7/" class="nav-link">Linux</a></li><li class="dropdown-item"><!----> <a href="/pages/2dcfa1/" class="nav-link">算法</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="数据库" class="dropdown-title"><!----> <span class="title" style="display:;">数据库</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/efa3f2/" class="nav-link">基础篇</a></li><li class="dropdown-item"><!----> <a href="/pages/ccc445/" class="nav-link">MySql</a></li><li class="dropdown-item"><!----> <a href="/pages/54616e/" class="nav-link">Redis</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="嵌入式软件开发" class="dropdown-title"><!----> <span class="title" style="display:;">嵌入式软件开发</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/d142c2/" class="nav-link">电子嵌入式通信协议</a></li><li class="dropdown-item"><!----> <a href="/pages/4c6bf3/" class="nav-link">深入浅出SSD</a></li><li class="dropdown-item"><!----> <a href="/pages/d3f36a/" class="nav-link">文件系统</a></li><li class="dropdown-item"><!----> <a href="/pages/e0cca7/" class="nav-link">汇编语言</a></li><li class="dropdown-item"><!----> <a href="/pages/fab2d7/" class="nav-link">STM32</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="开发日常" class="dropdown-title"><!----> <span class="title" style="display:;">开发日常</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/e472d1/" class="nav-link">随笔（持续更新）</a></li><li class="dropdown-item"><!----> <a href="/pages/71f6ae/" class="nav-link">Git知识总结</a></li><li class="dropdown-item"><!----> <a href="/pages/db6fb8/" class="nav-link">Git备忘清单</a></li><li class="dropdown-item"><!----> <a href="/pages/e1081f/" class="nav-link">Git 创建删除远程分支</a></li><li class="dropdown-item"><!----> <a href="/pages/777b8a/" class="nav-link">nvm使用小结</a></li><li class="dropdown-item"><!----> <a href="/pages/ee770e/" class="nav-link">虚拟机固定 IP 地址</a></li><li class="dropdown-item"><!----> <a href="/pages/1ab9a6/" class="nav-link">Shell 脚本学习笔记</a></li><li class="dropdown-item"><!----> <a href="/pages/411aa4/" class="nav-link">VScode 插件 CodeGeeX 使用教程</a></li><li class="dropdown-item"><!----> <a href="/pages/0d525d/" class="nav-link">KylinV10 将项目上传至 Github教程</a></li><li class="dropdown-item"><!----> <a href="/pages/907786/" class="nav-link">KylinV10 安装 MySQL 教程（可防踩雷）</a></li><li class="dropdown-item"><!----> <a href="/pages/a2d21e/" class="nav-link">kylinV10-SP1 安装 QT</a></li><li class="dropdown-item"><!----> <a href="/pages/b561cf/" class="nav-link">高并发内存池</a></li><li class="dropdown-item"><!----> <a href="/pages/6ab6d1/" aria-current="page" class="nav-link router-link-exact-active router-link-active">USBGUARD 项目编译环境配置</a></li><li class="dropdown-item"><!----> <a href="/pages/883f02/" class="nav-link">Power_Destory 项目</a></li><li class="dropdown-item"><!----> <a href="/pages/479472/" class="nav-link">U 盘清除工具编译教程</a></li><li class="dropdown-item"><!----> <a href="/pages/9c4241/" class="nav-link">个人博客代码推送教程</a></li><li class="dropdown-item"><!----> <a href="/pages/3ad765/" class="nav-link">SVN Trunk Branches的Merge操作</a></li><li class="dropdown-item"><!----> <a href="/pages/0c0ca8/" class="nav-link">如何高效阅读嵌入式项目代码</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="前端学习" class="dropdown-title"><!----> <span class="title" style="display:;">前端学习</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/99897f/" class="nav-link">HTML与CSS</a></li><li class="dropdown-item"><!----> <a href="/pages/51542d/" class="nav-link">JS学习</a></li><li class="dropdown-item"><!----> <a href="/pages/803f9d/" class="nav-link">Vue3入门</a></li><li class="dropdown-item"><!----> <a href="/pages/ca4cfb/" class="nav-link">Vue3进阶</a></li><li class="dropdown-item"><!----> <a href="/pages/50e8d3/" class="nav-link">黑马Vue3</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="MFC" class="dropdown-title"><!----> <span class="title" style="display:;">MFC</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/a4b108/" class="nav-link">MFC编程随记</a></li><li class="dropdown-item"><!----> <a href="/pages/41acbd/" class="nav-link">MFC实现ini配置文件的读取</a></li><li class="dropdown-item"><!----> <a href="/pages/951a7a/" class="nav-link">MFC实现点击列表头排序</a></li><li class="dropdown-item"><!----> <a href="/pages/a8598f/" class="nav-link">贴图法美化Button按钮</a></li><li class="dropdown-item"><!----> <a href="/pages/054516/" class="nav-link">MFC使用细节</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="闪存" class="dropdown-title"><!----> <span class="title" style="display:;">闪存</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/b925b8/" class="nav-link">如何高效阅读嵌入式项目代码</a></li><li class="dropdown-item"><!----> <a href="/pages/28ec23/" class="nav-link">NAND Flash</a></li><li class="dropdown-item"><!----> <a href="/pages/62bf40/" class="nav-link">ARM 处理器</a></li><li class="dropdown-item"><!----> <a href="/pages/1a9374/" class="nav-link">嵌入式基础知识-存储器</a></li><li class="dropdown-item"><!----> <a href="/pages/aac5e3/" class="nav-link">闪存存储和制造技术概述</a></li><li class="dropdown-item"><!----> <a href="/pages/8f6056/" class="nav-link">芯片IO驱动力</a></li><li class="dropdown-item"><!----> <a href="/pages/d146b8/" class="nav-link">主流先进封装技术介绍</a></li><li class="dropdown-item"><!----> <a href="/pages/16f0ba/" class="nav-link">NAND Flash基础</a></li><li class="dropdown-item"><!----> <a href="/pages/90d8d0/" class="nav-link">基于PA算法的FTL引导</a></li><li class="dropdown-item"><!----> <a href="/pages/eb672b/" class="nav-link">SD逻辑擦除和物理擦除</a></li><li class="dropdown-item"><!----> <a href="/pages/747121/" class="nav-link">NAND Flash的SDR、ONFI、DDR接口</a></li><li class="dropdown-item"><!----> <a href="/pages/1eb351/" class="nav-link">【详解】Nand Flash必看知识</a></li><li class="dropdown-item"><!----> <a href="/pages/d2512a/" class="nav-link">【两万字详解】Nand Flash必看知识</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="面经" class="dropdown-title"><!----> <span class="title" style="display:;">面经</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/d69946/" class="nav-link">虎牙C++技术面经</a></li><li class="dropdown-item"><!----> <a href="/pages/29251d/" class="nav-link">金山一面复习</a></li><li class="dropdown-item"><!----> <a href="/pages/c7c01f/" class="nav-link">完美世界秋招 C++ 游戏开发面经(Cpp部分)</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="其它" class="dropdown-title"><!----> <span class="title" style="display:;">其它</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/fa256e/" class="nav-link">博客搭建</a></li><li class="dropdown-item"><!----> <a href="/pages/335531/" class="nav-link">网站收藏箱</a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <div class="sidebar-hover-trigger"></div> <aside class="sidebar" style="display:none;"><!----> <nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="CPP语言" class="dropdown-title"><!----> <span class="title" style="display:;">CPP语言</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/c5bdd8/" class="nav-link">Cpp之旅</a></li><li class="dropdown-item"><!----> <a href="/pages/279e62/" class="nav-link">Cpp专栏</a></li><li class="dropdown-item"><!----> <a href="/pages/801755/" class="nav-link">Effective_CPP</a></li><li class="dropdown-item"><!----> <a href="/pages/6b2468/" class="nav-link">muduo网络库</a></li><li class="dropdown-item"><!----> <a href="/pages/5f8c9f/" class="nav-link">Unix环境高级编程</a></li><li class="dropdown-item"><!----> <a href="/pages/3f1d21/" class="nav-link">Cpp提高编程</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="计算机基础" class="dropdown-title"><!----> <span class="title" style="display:;">计算机基础</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/7b1cb2/" class="nav-link">计算机网络</a></li><li class="dropdown-item"><!----> <a href="/pages/6048a8/" class="nav-link">操作系统</a></li><li class="dropdown-item"><!----> <a href="/pages/3b34ba/" class="nav-link">数据结构</a></li><li class="dropdown-item"><!----> <a href="/pages/412fe7/" class="nav-link">Linux</a></li><li class="dropdown-item"><!----> <a href="/pages/2dcfa1/" class="nav-link">算法</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="数据库" class="dropdown-title"><!----> <span class="title" style="display:;">数据库</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/efa3f2/" class="nav-link">基础篇</a></li><li class="dropdown-item"><!----> <a href="/pages/ccc445/" class="nav-link">MySql</a></li><li class="dropdown-item"><!----> <a href="/pages/54616e/" class="nav-link">Redis</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="嵌入式软件开发" class="dropdown-title"><!----> <span class="title" style="display:;">嵌入式软件开发</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/d142c2/" class="nav-link">电子嵌入式通信协议</a></li><li class="dropdown-item"><!----> <a href="/pages/4c6bf3/" class="nav-link">深入浅出SSD</a></li><li class="dropdown-item"><!----> <a href="/pages/d3f36a/" class="nav-link">文件系统</a></li><li class="dropdown-item"><!----> <a href="/pages/e0cca7/" class="nav-link">汇编语言</a></li><li class="dropdown-item"><!----> <a href="/pages/fab2d7/" class="nav-link">STM32</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="开发日常" class="dropdown-title"><!----> <span class="title" style="display:;">开发日常</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/e472d1/" class="nav-link">随笔（持续更新）</a></li><li class="dropdown-item"><!----> <a href="/pages/71f6ae/" class="nav-link">Git知识总结</a></li><li class="dropdown-item"><!----> <a href="/pages/db6fb8/" class="nav-link">Git备忘清单</a></li><li class="dropdown-item"><!----> <a href="/pages/e1081f/" class="nav-link">Git 创建删除远程分支</a></li><li class="dropdown-item"><!----> <a href="/pages/777b8a/" class="nav-link">nvm使用小结</a></li><li class="dropdown-item"><!----> <a href="/pages/ee770e/" class="nav-link">虚拟机固定 IP 地址</a></li><li class="dropdown-item"><!----> <a href="/pages/1ab9a6/" class="nav-link">Shell 脚本学习笔记</a></li><li class="dropdown-item"><!----> <a href="/pages/411aa4/" class="nav-link">VScode 插件 CodeGeeX 使用教程</a></li><li class="dropdown-item"><!----> <a href="/pages/0d525d/" class="nav-link">KylinV10 将项目上传至 Github教程</a></li><li class="dropdown-item"><!----> <a href="/pages/907786/" class="nav-link">KylinV10 安装 MySQL 教程（可防踩雷）</a></li><li class="dropdown-item"><!----> <a href="/pages/a2d21e/" class="nav-link">kylinV10-SP1 安装 QT</a></li><li class="dropdown-item"><!----> <a href="/pages/b561cf/" class="nav-link">高并发内存池</a></li><li class="dropdown-item"><!----> <a href="/pages/6ab6d1/" aria-current="page" class="nav-link router-link-exact-active router-link-active">USBGUARD 项目编译环境配置</a></li><li class="dropdown-item"><!----> <a href="/pages/883f02/" class="nav-link">Power_Destory 项目</a></li><li class="dropdown-item"><!----> <a href="/pages/479472/" class="nav-link">U 盘清除工具编译教程</a></li><li class="dropdown-item"><!----> <a href="/pages/9c4241/" class="nav-link">个人博客代码推送教程</a></li><li class="dropdown-item"><!----> <a href="/pages/3ad765/" class="nav-link">SVN Trunk Branches的Merge操作</a></li><li class="dropdown-item"><!----> <a href="/pages/0c0ca8/" class="nav-link">如何高效阅读嵌入式项目代码</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="前端学习" class="dropdown-title"><!----> <span class="title" style="display:;">前端学习</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/99897f/" class="nav-link">HTML与CSS</a></li><li class="dropdown-item"><!----> <a href="/pages/51542d/" class="nav-link">JS学习</a></li><li class="dropdown-item"><!----> <a href="/pages/803f9d/" class="nav-link">Vue3入门</a></li><li class="dropdown-item"><!----> <a href="/pages/ca4cfb/" class="nav-link">Vue3进阶</a></li><li class="dropdown-item"><!----> <a href="/pages/50e8d3/" class="nav-link">黑马Vue3</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="MFC" class="dropdown-title"><!----> <span class="title" style="display:;">MFC</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/a4b108/" class="nav-link">MFC编程随记</a></li><li class="dropdown-item"><!----> <a href="/pages/41acbd/" class="nav-link">MFC实现ini配置文件的读取</a></li><li class="dropdown-item"><!----> <a href="/pages/951a7a/" class="nav-link">MFC实现点击列表头排序</a></li><li class="dropdown-item"><!----> <a href="/pages/a8598f/" class="nav-link">贴图法美化Button按钮</a></li><li class="dropdown-item"><!----> <a href="/pages/054516/" class="nav-link">MFC使用细节</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="闪存" class="dropdown-title"><!----> <span class="title" style="display:;">闪存</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/b925b8/" class="nav-link">如何高效阅读嵌入式项目代码</a></li><li class="dropdown-item"><!----> <a href="/pages/28ec23/" class="nav-link">NAND Flash</a></li><li class="dropdown-item"><!----> <a href="/pages/62bf40/" class="nav-link">ARM 处理器</a></li><li class="dropdown-item"><!----> <a href="/pages/1a9374/" class="nav-link">嵌入式基础知识-存储器</a></li><li class="dropdown-item"><!----> <a href="/pages/aac5e3/" class="nav-link">闪存存储和制造技术概述</a></li><li class="dropdown-item"><!----> <a href="/pages/8f6056/" class="nav-link">芯片IO驱动力</a></li><li class="dropdown-item"><!----> <a href="/pages/d146b8/" class="nav-link">主流先进封装技术介绍</a></li><li class="dropdown-item"><!----> <a href="/pages/16f0ba/" class="nav-link">NAND Flash基础</a></li><li class="dropdown-item"><!----> <a href="/pages/90d8d0/" class="nav-link">基于PA算法的FTL引导</a></li><li class="dropdown-item"><!----> <a href="/pages/eb672b/" class="nav-link">SD逻辑擦除和物理擦除</a></li><li class="dropdown-item"><!----> <a href="/pages/747121/" class="nav-link">NAND Flash的SDR、ONFI、DDR接口</a></li><li class="dropdown-item"><!----> <a href="/pages/1eb351/" class="nav-link">【详解】Nand Flash必看知识</a></li><li class="dropdown-item"><!----> <a href="/pages/d2512a/" class="nav-link">【两万字详解】Nand Flash必看知识</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="面经" class="dropdown-title"><!----> <span class="title" style="display:;">面经</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/d69946/" class="nav-link">虎牙C++技术面经</a></li><li class="dropdown-item"><!----> <a href="/pages/29251d/" class="nav-link">金山一面复习</a></li><li class="dropdown-item"><!----> <a href="/pages/c7c01f/" class="nav-link">完美世界秋招 C++ 游戏开发面经(Cpp部分)</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="其它" class="dropdown-title"><!----> <span class="title" style="display:;">其它</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pages/fa256e/" class="nav-link">博客搭建</a></li><li class="dropdown-item"><!----> <a href="/pages/335531/" class="nav-link">网站收藏箱</a></li></ul></div></div> <!----></nav>  <ul class="sidebar-links"><li><a href="/pages/71f6ae/" class="sidebar-link">Git知识总结</a></li><li><a href="/pages/777b8a/" class="sidebar-link">nvm使用小结</a></li><li><a href="/pages/e472d1/" class="sidebar-link">随笔（持续更新）</a></li><li><a href="/pages/ee770e/" class="sidebar-link">虚拟机固定ip地址</a></li><li><a href="/pages/411aa4/" class="sidebar-link">VScode 插件 CodeGeex 使用教程</a></li><li><a href="/pages/0d525d/" class="sidebar-link">KylinV10 将项目上传至 Github</a></li><li><a href="/pages/907786/" class="sidebar-link">KylinV10 安装 MySQL 教程（可防踩雷）</a></li><li><a href="/pages/9c4241/" class="sidebar-link">个人博客代码推送教程</a></li><li><a href="/pages/a2d21e/" class="sidebar-link">kylinV10-SP1 安装 QT</a></li><li><a href="/pages/b561cf/" class="sidebar-link">高并发内存池</a></li><li><a href="/pages/6ab6d1/" aria-current="page" class="active sidebar-link">USBGUARD项目编译环境配置</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level2"><a href="/pages/6ab6d1/#_3-1-缺少-automake-1-16-包的问题" class="sidebar-link">3.1 缺少 automake-1.16 包的问题</a></li><li class="sidebar-sub-header level2"><a href="/pages/6ab6d1/#_3-2-no-package-libxml-2-0-found-的问题" class="sidebar-link">3.2 No package 'libxml-2.0' found 的问题</a></li><li class="sidebar-sub-header level2"><a href="/pages/6ab6d1/#_3-3-undefined-macro-ac-msg-error-的问题" class="sidebar-link">3.3 undefined macro : AC MSG_ERROR 的问题</a></li><li class="sidebar-sub-header level2"><a href="/pages/6ab6d1/#_3-4-no-xxx-三方库的问题" class="sidebar-link">3.4 No xxx 三方库的问题</a></li><li class="sidebar-sub-header level2"><a href="/pages/6ab6d1/#_4-1-编译后台程序-usbguard" class="sidebar-link">4.1 编译后台程序 usbguard</a></li><li class="sidebar-sub-header level2"><a href="/pages/6ab6d1/#_4-2-编译桌面程序-usbdesk" class="sidebar-link">4.2 编译桌面程序 usbdesk</a></li><li class="sidebar-sub-header level2"><a href="/pages/6ab6d1/#_4-3-编译注册程序-power-reg" class="sidebar-link">4.3 编译注册程序 power_reg</a></li><li class="sidebar-sub-header level2"><a href="/pages/6ab6d1/#_4-4-编译-tqfairwall" class="sidebar-link">4.4 编译 tqFairWall</a></li><li class="sidebar-sub-header level2"><a href="/pages/6ab6d1/#_4-5-单机版本地运行" class="sidebar-link">4.5 单机版本地运行</a></li><li class="sidebar-sub-header level2"><a href="/pages/6ab6d1/#_4-6-运行项目" class="sidebar-link">4.6 运行项目</a></li><li class="sidebar-sub-header level2"><a href="/pages/6ab6d1/#_7-1-usb-规则类型" class="sidebar-link">7.1 USB 规则类型</a></li><li class="sidebar-sub-header level2"><a href="/pages/6ab6d1/#_7-2-了解-etc-usbguard-usbguard-daemon-conf-配置" class="sidebar-link">7.2 了解 /etc/usbguard/usbguard-daemon.conf 配置</a></li><li class="sidebar-sub-header level2"><a href="/pages/6ab6d1/#_7-3-列出-usbguard-守护程序使用的规则集-策略" class="sidebar-link">7.3 列出 USBGuard 守护程序使用的规则集（策略）</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header level3"><a href="/pages/6ab6d1/#_7-3-1-使用以下命令可以列出规则集" class="sidebar-link">7.3.1 使用以下命令可以列出规则集：</a></li><li class="sidebar-sub-header level3"><a href="/pages/6ab6d1/#_7-3-2-显示受特定规则影响的所有设备" class="sidebar-link">7.3.2 显示受特定规则影响的所有设备</a></li><li class="sidebar-sub-header level3"><a href="/pages/6ab6d1/#_7-3-3-还可以显示具有特定标签的规则" class="sidebar-link">7.3.3 还可以显示具有特定标签的规则</a></li><li class="sidebar-sub-header level3"><a href="/pages/6ab6d1/#_7-3-4-列出-usbguard-守护程序识别的所有-usb-设备" class="sidebar-link">7.3.4 列出 USBGuard 守护程序识别的所有 USB 设备</a></li></ul></li><li class="sidebar-sub-header level2"><a href="/pages/6ab6d1/#_8-1-测试-usb-插入是否默认阻止" class="sidebar-link">8.1 测试 USB 插入是否默认阻止</a></li><li class="sidebar-sub-header level2"><a href="/pages/6ab6d1/#_8-2-暂时允许访问-usb-设备" class="sidebar-link">8.2 暂时允许访问 USB 设备</a></li><li class="sidebar-sub-header level2"><a href="/pages/6ab6d1/#_8-3-永久规则" class="sidebar-link">8.3 永久规则</a></li><li class="sidebar-sub-header level2"><a href="/pages/6ab6d1/#_8-4-检查" class="sidebar-link">8.4 检查</a></li></ul></li><li><a href="/pages/1ab9a6/" class="sidebar-link">Shell 脚本学习笔记</a></li><li><a href="/pages/db6fb8/" class="sidebar-link">Git 备忘清单</a></li><li><a href="/pages/883f02/" class="sidebar-link">Power_Destory 项目</a></li><li><a href="/pages/479472/" class="sidebar-link">U盘清除工具编译教程</a></li><li><a href="/pages/e1081f/" class="sidebar-link">Git 创建删除远程分支</a></li><li><a href="/pages/3ad765/" class="sidebar-link">SVN Trunk Branches的Merge操作</a></li><li><a href="/pages/0c0ca8/" class="sidebar-link">如何高效阅读嵌入式项目代码</a></li></ul> </aside> <div><main class="page"><div class="theme-vdoing-wrapper "><div class="articleInfo-wrap" data-v-06225672><div class="articleInfo" data-v-06225672><ul class="breadcrumbs" data-v-06225672><li data-v-06225672><a href="/" title="首页" class="iconfont icon-home router-link-active" data-v-06225672></a></li> <li data-v-06225672><span data-v-06225672>开发日常</span></li></ul> <div class="info" data-v-06225672><div title="作者" class="author iconfont icon-touxiang" data-v-06225672><a href="javascript:;" data-v-06225672>霜晨月</a></div> <div title="创建时间" class="date iconfont icon-riqi" data-v-06225672><a href="javascript:;" data-v-06225672>2024-01-17</a></div> <!----></div></div></div> <!----> <div class="content-wrapper"><div class="right-menu-wrapper"><div class="right-menu-margin"><div class="right-menu-title">目录</div> <div class="right-menu-content"></div></div></div> <h1><img src="">USBGUARD项目编译环境配置<!----></h1> <!----> <div class="theme-vdoing-content content__default"><h1 id="usbguard项目编译环境配置"><a href="#usbguard项目编译环境配置" class="header-anchor">#</a> USBGUARD项目编译环境配置</h1> <h1 id="_1-主要目录结构"><a href="#_1-主要目录结构" class="header-anchor">#</a> 1. 主要目录结构</h1> <div class="language-pascal line-numbers-mode"><pre class="language-pascal"><code>kylin<span class="token operator">@</span>kylinV10<span class="token punctuation">:</span><span class="token operator">/</span>data$ <span class="token punctuation">(</span>项目搭建在根目录下的data目录里<span class="token punctuation">)</span>

data
│   
├── tq_usb
│   ├── thirdparty（三方库目录）
│	│   ├── build<span class="token punctuation">.</span>sh
│	│   ├── libhv_new（libhv 第三方库）
│	│   ├── libqb
│	│   ├── libsodium
│	│   ├── libxml2<span class="token operator">-</span>master
│	│   ├── openssl<span class="token operator">-</span><span class="token number">1.0</span><span class="token punctuation">.</span><span class="token number">2</span>g
│	│   ├── protobuf
│	│   ├── util<span class="token operator">-</span>linux<span class="token operator">-</span>smxa
│	│   └── xz<span class="token operator">-</span><span class="token number">5.2</span><span class="token punctuation">.</span><span class="token number">5</span>（lzma 第三方库）
│   ├── make_package<span class="token punctuation">(</span>制作安装包的目录<span class="token punctuation">)</span>
│	│   ├── 安装注意事项<span class="token punctuation">.</span>txt
│	│   ├── config<span class="token punctuation">.</span>json
│	│   ├── copy_file<span class="token punctuation">.</span>sh（拷贝文件脚本）
│	│   ├── Packager<span class="token punctuation">.</span>py（制作安装包的脚本）
│	│   └── res
│   ├── usbdesktop<span class="token punctuation">(</span>编译桌面程序<span class="token punctuation">)</span>
│	│   ├── build<span class="token punctuation">.</span>sh
│	│   ├── run<span class="token punctuation">.</span>sh
│	├── power_reg<span class="token punctuation">(</span>编译注册程序<span class="token punctuation">)</span>
│   ├── tqFireWall<span class="token punctuation">(</span>编译防火墙拦截<span class="token punctuation">)</span>
│   │	├── command<span class="token punctuation">(</span>要编译<span class="token punctuation">)</span>
│   │	├── kernelmod<span class="token punctuation">(</span>要编译<span class="token punctuation">)</span>
│   │	└── usermod<span class="token punctuation">(</span>不用编译<span class="token punctuation">)</span>
│   ├── usbguard
│   │	├── autogen<span class="token punctuation">.</span>sh
│   │	└── init_build<span class="token punctuation">.</span>sh
├── lost<span class="token operator">+</span>found
├── root
└── usershare
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br></div></div><h1 id="_2-编译项目前的配置"><a href="#_2-编译项目前的配置" class="header-anchor">#</a> 2. 编译项目前的配置</h1> <p>运行第三方库脚本安装前的前置条件：</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> <span class="token function">apt</span> <span class="token parameter variable">-y</span> <span class="token function">install</span> libdbus-1-dev
<span class="token function">sudo</span> <span class="token function">apt</span> <span class="token parameter variable">-y</span> <span class="token function">install</span> libpolkit-gobject-1-dev
<span class="token function">sudo</span> <span class="token function">apt</span> <span class="token parameter variable">-y</span> <span class="token function">install</span> libglib2.0-dev
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h1 id="_3-运行三方库的脚本"><a href="#_3-运行三方库的脚本" class="header-anchor">#</a> 3. 运行三方库的脚本</h1> <p>在 <code>/data/tq_usb/thirdparty</code>路径下找到<code>build.sh</code>脚本</p> <blockquote><p>建议现在每个三方库目录里面创建一个 do_build 目录，已经有 do_build 目录的就不用管，如果没有 do_build 目录执行脚本会报找不到第三方库的问题！</p> <p><img alt="1705369475951" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705369475951.webp" loading="lazy" class="lazy"></p></blockquote> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token builtin class-name">cd</span> /data/tq_usb/thirdparty
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p><img alt="1704865561035" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1704865561035.webp" loading="lazy" class="lazy"></p> <p>执行以下命令</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># 最新版可以一键编译</span>
./build.sh x86_64 kylin

<span class="token comment"># kylin x86_64 环境用以下命令</span>
./build.sh x86_64 kylin findmnt
./build.sh x86_64 kylin ssl
./build.sh x86_64 kylin lzma
./build.sh x86_64 kylin xml2
./build.sh x86_64 kylin qb
./build.sh x86_64 kylin protobuf
./build.sh x86_64 kylin sodium
./build.sh x86_64 kylin hv

<span class="token comment"># kylin aarch64 环境用以下命令</span>
./build.sh aarch64 kylin findmnt
./build.sh aarch64 kylin ssl
./build.sh aarch64 kylin lzma
./build.sh aarch64 kylin lzma
./build.sh aarch64 kylin xml2
./build.sh aarch64 kylin qb
./build.sh aarch64 kylin protobuf
./build.sh aarch64 kylin sodium
./build.sh aarch64 kylin hv

<span class="token comment"># UOS mips 环境用以下命令</span>
./build.sh mips kylin findmnt
./build.sh mips kylin ssl
./build.sh mips kylin lzma
./build.sh mips UOS lzma
./build.sh mips UOS xml2
./build.sh mips UOS qb
./build.sh mips UOS protobuf
./build.sh mips UOS sodium
./build.sh mips UOS hv
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br></div></div><h2 id="_3-1-缺少-automake-1-16-包的问题"><a href="#_3-1-缺少-automake-1-16-包的问题" class="header-anchor">#</a> 3.1 缺少 automake-1.16 包的问题</h2> <p>执行脚本有可能会报缺少 automake-1.16</p> <p><img alt="1704865976223" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1704865976223.webp" loading="lazy" class="lazy"></p> <p>表明在尝试编译 xz-5.2.5 这个软件包时，automake-1.16 工具没有在您的系统上找到。automake 是 GNU Automake 包的一部分，它用于生成 Makefile.in 文件，这是由 autoconf 用于生成最终 Makefile 的基础文件。<strong>要解决这个问题，需要安装 GNU Automake 包以及它的依赖项。</strong></p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># 执行</span>
<span class="token function">sudo</span> <span class="token function">apt-get</span> <span class="token function">install</span> automake autoconf2.13 m4 perl
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><hr> <h2 id="_3-2-no-package-libxml-2-0-found-的问题"><a href="#_3-2-no-package-libxml-2-0-found-的问题" class="header-anchor">#</a> 3.2 No package 'libxml-2.0' found 的问题</h2> <p>如果执行 <code>./build.sh x86_64 kylin</code> 脚本命令出现如下错误，就往 3.3 步骤继续走</p> <p><img alt="1705312293484" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705312293484.webp" loading="lazy" class="lazy"></p> <hr> <h2 id="_3-3-undefined-macro-ac-msg-error-的问题"><a href="#_3-3-undefined-macro-ac-msg-error-的问题" class="header-anchor">#</a> 3.3 undefined macro : AC MSG_ERROR 的问题</h2> <p>就找到每一个库，进入该第三方库就行单独编译，<code>./autogen.sh</code> 脚本，如果还出现以下错误</p> <p><img alt="1705368449552" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705368449552.webp" loading="lazy" class="lazy"></p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># 输入以下命令</span>
<span class="token function">sudo</span> <span class="token function">apt-get</span> <span class="token function">install</span> autoconf-archive
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>出现如下图所示就表示编译通过</p> <p><img alt="1705369028548" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705369028548.webp" loading="lazy" class="lazy"></p> <p>如果还无法解决可以参考这个链接的内容：https://www.thinbug.com/q/8811381</p> <hr> <h2 id="_3-4-no-xxx-三方库的问题"><a href="#_3-4-no-xxx-三方库的问题" class="header-anchor">#</a> 3.4 No xxx 三方库的问题</h2> <p>如果执行 <code>./build.sh x86_64 kylin</code> 脚本命令出现错误，就一个库一个库编译，比如编译 lzma(即 xz-5.2.5)库 <code>./build.sh x86_64 kylin lzma</code> 出现无法找到的问题，进入该三方库 <code>cd xz-5.2.5</code>，创建一个 <code>do_build</code> 目录，在返回上一级目录，重新编译 <code>./build.sh x86_64 kylin lzma</code> 命令就可以了</p> <p><img alt="1705369475951" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705369475951.webp" loading="lazy" class="lazy"></p> <p>第三方库都安装完成就可以进行下一步编译项目源码</p> <h1 id="_4-编译项目源码"><a href="#_4-编译项目源码" class="header-anchor">#</a> 4. 编译项目源码</h1> <h2 id="_4-1-编译后台程序-usbguard"><a href="#_4-1-编译后台程序-usbguard" class="header-anchor">#</a> 4.1 编译后台程序 usbguard</h2> <p>进入 <code>/data/tq_usb/usbguard</code> 目录，创建 <code>do_build</code> 目录，有的话就不用创建，直接清空就行</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># usbguard 目录没有 do_build 目录就创建</span>
<span class="token function">mkdir</span> do_build
<span class="token comment"># 有的话就清空</span>
<span class="token builtin class-name">cd</span> do_build <span class="token operator">&amp;&amp;</span> <span class="token function">rm</span> <span class="token parameter variable">-fr</span> *
<span class="token builtin class-name">cd</span> /data/tq_usb/usbguard <span class="token operator">&amp;&amp;</span> <span class="token punctuation">..</span>/autogen.sh

<span class="token builtin class-name">cd</span> /data/tq_usb/usbguard/do_build <span class="token operator">&amp;&amp;</span> <span class="token function">cp</span> <span class="token punctuation">..</span>/init_build.sh <span class="token builtin class-name">.</span>
./init_build.sh

<span class="token comment"># 然后执行</span>
<span class="token function">make</span> <span class="token function">install</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br></div></div><p>在 <code>do_build</code> 目录执行完 <code>../configure</code> 后如果出现以下错误：</p> <p><img alt="1705371397466" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705371397466.webp" loading="lazy" class="lazy"></p> <p>进入 <code>/data/tq_usb/release/x86_64/kylin-v10/lib/pkgconfig</code> 查看是否有 <code>libhv.pc</code> 文件，其他三方库也在这里</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>cd /data/tq_usb/release/x86_64/kylin-v10/lib/pkgconfig
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p><img alt="1705383471608" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705383471608.webp" loading="lazy" class="lazy"></p> <p>如果没有，则需要 ssh 远程连接其他终端上通过内网拉取，拷贝到这个目录，然后修改路径 <code>vim libhv.pc</code> 其他三方库出现这个问题也一样。</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">ssh</span> luokp@192.168.0.26
<span class="token comment"># 提示：电脑开机输入的密码</span>
<span class="token comment"># 路径如下：</span>
<span class="token builtin class-name">cd</span> /media/luokp/DATA/workspace/tq_usb/release/x86_64/kylin-v10/lib
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p><strong>拷贝到自己的电脑后，要改这拷贝文件的路径。</strong></p> <p>如下图所示，把下图的 prefix 的路径改为自己项目所在的路径，不知道怎么改可以查看一下同目录下的 libqb.pc 的 prefix 字段的路径</p> <p><img alt="1705383662795" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705383662795.webp" loading="lazy" class="lazy"></p> <p><strong>最后就在 <code>do_build</code> 目录继续进行 4.1 步骤</strong>，就会生成如下几个可执行文件和配置文件</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># 接着执行</span>
<span class="token function">make</span> <span class="token function">install</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p><img alt="1705389726815" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705389726815.webp" loading="lazy" class="lazy"></p> <hr> <p>编译过程如果无报错则继续往下走，有报错，则自行根据具体报错解决。</p> <h2 id="_4-2-编译桌面程序-usbdesk"><a href="#_4-2-编译桌面程序-usbdesk" class="header-anchor">#</a> 4.2 编译桌面程序 usbdesk</h2> <p>运行脚本前先看看路径，因为不同终端的编译路径可能会不一样。（改 CMakeList.txt 文件）</p> <p>这个是 <code>/data/tq_usb/usbdesktop/</code> 目录下的 <code>run.sh</code> 文件，这个文件是本地运行项目要用的</p> <p><img alt="1705386595330" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705386595330.webp" loading="lazy" class="lazy"></p> <p><img alt="1706669251810" data-src="https://jsd.cdn.zzko.cn/gh/xiaose-code/Pictures@main/img/1706669251810.webp" loading="lazy" class="lazy"></p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code>./usbdesk <span class="token parameter variable">-b</span> <span class="token string">&quot;&quot;</span> <span class="token parameter variable">-m</span> network <span class="token parameter variable">-c</span> <span class="token variable">${<span class="token environment constant">PWD</span>}</span>/<span class="token punctuation">..</span>/etc/usbdesk.conf
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>这里修改的原因可以对照 ``/data/tq_usb/usbdesktop` main.cpp</p> <p>如果不是在 x86 端编译，而是在 aarch64 端编译要看看 <code>/data/tq_usb/usbdesktop/</code> 目录下的 <code>CMakeList.txt</code> 文件（mips64端就类似与aarch64这样改就行）</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token builtin class-name">cd</span> /data/tq_usb/usbdesktop
<span class="token function">vim</span> CMakeList.txt
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p><img alt="1705651273840" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705651273840.webp" loading="lazy" class="lazy"></p> <p>进入 <code>/data/tq_usb/usbdesktop/do_build</code> 目录，运行 <code>build.sh</code> 和 <code>run.sh</code> 脚本</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># usbdesktop 目录没有 do_build 目录就创建</span>
<span class="token builtin class-name">cd</span> /data/tq_usb/usbdesktop/ <span class="token operator">&amp;&amp;</span> <span class="token function">mkdir</span> do_build
<span class="token builtin class-name">cd</span> do_build <span class="token operator">&amp;&amp;</span> <span class="token function">cp</span> <span class="token punctuation">..</span>/build.sh <span class="token builtin class-name">.</span>
./build.sh

<span class="token comment"># 如果本身有 do_build 目录的话就清空</span>
<span class="token function">rm</span> <span class="token parameter variable">-fr</span> do_build/*
<span class="token builtin class-name">cd</span> /data/tq_usb/usbdesktop/do_build <span class="token operator">&amp;&amp;</span> <span class="token function">cp</span> <span class="token punctuation">..</span>/build.sh <span class="token builtin class-name">.</span>
./build.sh
<span class="token comment"># 然后执行</span>
<span class="token function">make</span> <span class="token parameter variable">-j8</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br></div></div><p>笔者这里运行 <code>build.sh</code> 脚本是因为缺少了 qt5 的部分组件，所以报错了，有类似的可以参考</p> <p><img alt="1705387325407" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705387325407.webp" loading="lazy" class="lazy"></p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># 直接命令行下载（前提是你的QT5也是用命令行下载的）</span>
<span class="token function">sudo</span> <span class="token function">apt-get</span> <span class="token function">install</span> qttools5-dev-tools
<span class="token comment"># 如果没有解决就把 多余的 QT安装包删了</span>
<span class="token function">sudo</span> <span class="token function">apt</span> remove qttools5-dev-tools
<span class="token comment"># 然后你会看到他叫你可以删除多余的不需要的安装包，都删了</span>
<span class="token function">sudo</span> <span class="token function">apt</span> autoremove

<span class="token comment"># 然后再重新下载</span>
<span class="token function">sudo</span> <span class="token function">apt-get</span> <span class="token function">install</span> qttools5-dev-tools
<span class="token comment"># 在下载多一个插件试试</span>
<span class="token function">sudo</span> <span class="token function">apt</span> <span class="token function">install</span> qttools5-dev
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br></div></div><p>删除多余的安装包，如下图：</p> <p><img alt="1705389373449" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705389373449.webp" loading="lazy" class="lazy"></p> <p>编译成功，如下图：</p> <p><img alt="1705389058070" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705389058070.webp" loading="lazy" class="lazy"></p> <p>然后接着继续编译源码，还是在 <code>do_build</code> 目录执行 <code>make -j8</code></p> <p>然后在 <code>do_build</code> 目录就生成了桌面程序 <code>usbdesk</code></p> <p><img alt="1705389619953" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705389619953.webp" loading="lazy" class="lazy"></p> <hr> <h2 id="_4-3-编译注册程序-power-reg"><a href="#_4-3-编译注册程序-power-reg" class="header-anchor">#</a> 4.3 编译注册程序 power_reg</h2> <p>同样先进入脚本查看路径，因为这个是 QT 编写的程序，所以这里的脚本应该是以 <code>.pro</code> 结尾的文件</p> <p><img alt="1705390104544" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705390104544.webp" loading="lazy" class="lazy"></p> <hr> <p>进入 <code>/data/tq_usb/power_reg/do_build</code> 目录，执行 <code>qmake ..</code></p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># power_reg 目录没有 do_build 目录就创建</span>
<span class="token builtin class-name">cd</span> /data/tq_usb/power_reg/ <span class="token operator">&amp;&amp;</span> <span class="token function">mkdir</span> do_build

<span class="token comment"># 原来就有 do_build 目录的话就清空</span>
<span class="token function">rm</span> <span class="token parameter variable">-fr</span> do_build/*

<span class="token comment"># 然后执行</span>
qmake <span class="token punctuation">..</span>
---------------------执行结果如下：---------------------------------------------
kylin@kylin:/data/tq_usb/power_reg/do_build$ qmake <span class="token punctuation">..</span>
Info: creating stash <span class="token function">file</span> /data/tq_usb/power_reg/do_build/.qmake.stash
Project MESSAGE: <span class="token assign-left variable">VAR_OS</span><span class="token operator">=</span>kylin
Project MESSAGE: <span class="token assign-left variable">VAR_OS_VER</span><span class="token operator">=</span>v10
Project MESSAGE: <span class="token assign-left variable">ARCH</span><span class="token operator">=</span>x86_64
------------------------------------------------------------------------

<span class="token comment"># 然后执行</span>
<span class="token function">make</span> <span class="token parameter variable">-j8</span>
<span class="token comment"># 执行完毕后就会在</span>
<span class="token comment"># /data/tq_usb/release/x86_64/kylin-v10/bin 这个目录下生成 可执行文件 PowerReg</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br></div></div><h2 id="_4-4-编译-tqfairwall"><a href="#_4-4-编译-tqfairwall" class="header-anchor">#</a> 4.4 编译 tqFairWall</h2> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token builtin class-name">cd</span> /data/tq_usb/tqFireWall/kernelmod
<span class="token function">make</span>
<span class="token comment"># 执行完之后 kernelmod 会有一个 tqfw.ko 文件</span>
-------------------------------------------------------------------------
<span class="token builtin class-name">cd</span> /data/tq_usb/tqFireWall/command
<span class="token function">make</span>
执行完之后 <span class="token builtin class-name">command</span> 会有一个可执行文件 fairwall
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h2 id="_4-5-单机版本地运行"><a href="#_4-5-单机版本地运行" class="header-anchor">#</a> 4.5 单机版本地运行</h2> <blockquote><p>项目源码编译通过再按下面步骤走</p></blockquote> <p>进入 <code>/data/tq_usb/usbguard/src/DBus/</code> 目录，将 <code>org.usbguard1.policy</code> 文件中的所有 <code>auth_admin</code> 该为 yes</p> <blockquote><p>这里介绍一个快捷的方式：vim 的手动批量替换（可以防止一键自动替换错地方）</p> <ol><li><p>首先，我们需要找到我们想要替换的文字。通过在普通模式下按 <code>/</code> 键并输入我们想要搜索的词语，Vim 就会高亮显示出所有文档中匹配该词语的地方，按下 <code>Enter</code> 键以确定搜索。</p></li> <li><p>然后通过<code>n</code>和<code>N</code>键在搜索结果中向前和向后跳转。<code>n</code>键会将光标移动到下一个搜索结果，<code>N</code>键则会将光标移动到上一个搜索结果。</p></li> <li><p>当我们找到了要替换的词语，我们可以通过<code>cw</code>命令将该词语替换为新的词语。在普通模式下，<code>cw</code>命令将删除从光标位置开始的词语，并进入插入模式，这允许我们输入新的词语。当我们完成新词语的输入后，通过按<code>Esc</code>键返回到普通模式。</p></li> <li><p>如果我们想要重复上一步的替换操作，我们可以简单地通过<code>.</code>命令来实现。在普通模式下，<code>.</code>命令将重复最后一次修改，这也包括了我们的替换操作。</p></li> <li><p>通过重复步骤 2 至 4，我们就可以实现对文档中所有匹配的词语的替换。</p> <p>这就是在 Vim 中完成批量替换操作的步骤。尽管最开始可能会觉得有些复杂，但是一旦熟练掌握，你就会发现这实际上是一个非常快速和高效的替换方法。</p></li></ol></blockquote> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token builtin class-name">cd</span> /data/tq_usb/usbguard/src/DBus/
<span class="token function">sudo</span> <span class="token function">vim</span> org.usbguard1.policy
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p><img alt="1705394377574" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705394377574.webp" loading="lazy" class="lazy"></p> <p>例如：框框中的 auto_admin（不止这两个地方）改为 yes</p> <p><img alt="1705394697922" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705394697922.webp" loading="lazy" class="lazy"></p> <hr> <p>将 <code>/data/tq_usb/usbguard/src/DBus/org.usbguard1.policy</code> 拷贝到 <code>/usr/share/polkit-1/actions/</code></p> <p>同时将 <code>/data/tq_usb/usbguard/src/DBus/org.usbguard1.conf</code> 拷贝到  <code>/usr/share/dbus-1/system.d</code> 下</p> <p><img alt="1704867038990" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1704867038990.webp" loading="lazy" class="lazy"></p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># 在 /data/tq_usb/usbguard/src/DBus 目录下</span>
<span class="token builtin class-name">cd</span> /data/tq_usb/usbguard/src/DBus
<span class="token function">sudo</span> <span class="token function">cp</span> org.usbguard1.policy /usr/share/polkit-1/actions/
<span class="token function">sudo</span> <span class="token function">cp</span> org.usbguard1.conf /usr/share/dbus-1/system.d
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>然后将 <code>/data/tq_usb/usbdesktop/etc</code> 目录下的 usbdesk.conf 文件中的进行修改</p> <div class="language-shell line-numbers-mode"><pre class="language-shell"><code><span class="token builtin class-name">cd</span> /data/tq_usb/usbdesktop/etc
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p><img alt="1708329835016" data-src="https://jsd.cdn.zzko.cn/gh/xiaose-code/Pictures@main/img/1708329835016.webp" loading="lazy" class="lazy"></p> <blockquote><p>usbdesk.conf文件后续又新增了有关防火漆的配置文件路径，注意路径！</p></blockquote> <p><img alt="image" data-src="https://jsd.cdn.zzko.cn/gh/xiaose-code/picx-images-hosting@master/img/image.13liqeketf.webp" loading="lazy" class="lazy"></p> <h2 id="_4-6-运行项目"><a href="#_4-6-运行项目" class="header-anchor">#</a> 4.6 运行项目</h2> <p>把 <code>/data/tq_usb/tqFireWall/kernelmod</code> 目录下的 tqfw.ko 文件拷贝到 <code>/data/tq_usb/release/x86_64/kylin-v10/etc/usbguard</code></p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token builtin class-name">cd</span> /data/tq_usb/release/x86_64/kylin-v10/etc/usbguard
<span class="token function">cp</span> /data/tq_usb/tqFireWall/kernelmod/tqfw.ko <span class="token builtin class-name">.</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>把 <code>/data/tq_usb/release/x86_64/kylin-v10/etc</code> 目录下的 usbguard 配置文件拷贝到 /etc 目录下</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token builtin class-name">cd</span> /etc
<span class="token function">sudo</span> <span class="token function">cp</span> <span class="token parameter variable">-fr</span> /data/tq_usb/release/x86_64/kylin-v10/etc/usbguard <span class="token builtin class-name">.</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p><img alt="image" data-src="https://jsd.cdn.zzko.cn/gh/xiaose-code/picx-images-hosting@master/img/image.4uaobnunli.webp" loading="lazy" class="lazy"></p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># 运行项目之前要先在 /data/tq_usb/usbguard/do_build 目录下执行配置文件，不然会把鼠标键盘全部禁用掉，就要重新开机了</span>
<span class="token builtin class-name">cd</span> /data/tq_usb/usbguard/do_build
<span class="token function">sudo</span> ./usbguard generate-policy <span class="token parameter variable">-c</span> /etc/usbguard/usbguard-daemon.conf

<span class="token comment"># 首先进入 do_build 目录下的</span>
<span class="token builtin class-name">cd</span> /data/tq_usb/usbguard/do_build
<span class="token function">sudo</span> ./usbguard-daemon <span class="token parameter variable">-d</span>
<span class="token comment"># 新开一个标签,返回 do_build 目录，执行</span>
<span class="token function">sudo</span> ./usbguard-dbus <span class="token parameter variable">-s</span>
<span class="token comment"># 再新开一个标签，是在 /data/tq_usb/usbdesktop/do_build 目录，执行</span>
<span class="token builtin class-name">cd</span> /data/tq_usb/usbdesktop/do_build
./run.sh
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><blockquote><p><strong>这里框框部分不用看，已经改了，不再用动态库，全部改为用静态库</strong></p> <p>在执行 <code>sudo ./usbguard-daemon</code> 时出现找不到某个共享库<img alt="1705395899224" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705395899224.webp" loading="lazy" class="lazy"></p> <p>要把 <code>/data/tq_usb/usbguard/do_build/.libs</code> 目录和 <code>/data/tq_usb/release/x86_64/kylin-v10/lib</code> 第三方库这两个路径加入到 <code>/etc/ld.so.conf.d/libc.conf</code> 文件里</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> <span class="token function">vim</span> /etc/ld.so.conf.d/libc.conf
<span class="token comment"># 改为之后记得刷新</span>
<span class="token function">sudo</span> ldconfig
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p><img alt="1705397511285" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705397511285.webp" loading="lazy" class="lazy"></p></blockquote> <h1 id="_5-打包成安装包"><a href="#_5-打包成安装包" class="header-anchor">#</a> 5. 打包成安装包</h1> <p>将 <code>/data/tq_usb/release/x86_64/kylin-v10/sbin/usbguard-daemon</code> 和 <code>/data/tq_usb/release/x86_64/kylin-v10/sbin/usbguard-dbus</code> 两个文件 copy 到 <code>/data/tq_usb/make_package/res/bin/</code>目录下</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token builtin class-name">cd</span> /data/tq_usb/make_package/res/bin
<span class="token function">cp</span> /data/tq_usb/release/x86_64/kylin-v10/sbin/usbguard-daemon <span class="token builtin class-name">.</span>
<span class="token function">cp</span> /data/tq_usb/release/x86_64/kylin-v10/sbin/usbguard-dbus <span class="token builtin class-name">.</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><hr> <p>将 <code>/data/tq_usb/release/x86_64/kylin-v10/bin</code> 目录下的 PowerReg、usbguard 两个文件</p> <p><code>/data/tq_usb/usbdesktop/do_build</code> 目录下的 usbdesk 这个文件</p> <p><code>/data/tq_usb/tqFireWall/command/</code> 下的 firewall 文件</p> <p>一共四个文件 copy 到 <code>/data/tq_usb/make_package/res/bin</code> 目录下</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">cp</span> /data/tq_usb/release/x86_64/kylin-v10/bin/PowerReg <span class="token builtin class-name">.</span>
<span class="token function">cp</span> /data/tq_usb/usbdesktop/do_build/usbdesk <span class="token builtin class-name">.</span>
<span class="token function">cp</span> /data/tq_usb/release/x86_64/kylin-v10/bin/usbguard <span class="token builtin class-name">.</span>
<span class="token function">cp</span> /data/tq_usb/tqFireWall/command/firewall <span class="token builtin class-name">.</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>然后将 <code>/data/tq_usb/tqFireWall/kernelmod</code> 下的 tqfw.ko 文件拷贝到 <code>/data/tq_usb/make_package/res/etc/usbguard</code> 目录下</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>cd /data/tq_usb/make_package/res/etc/usbguard
cp /data/tq_usb/tqFireWall/kernelmod/tqfw.ko .
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>到 <code>/data/tq_usb/make_package</code> 目录下找到 <code>Packager.py</code> 脚本执行</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>./Packager.py
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>输入版本号, 就会自动生成deb安装包</p> <p>第一次打包可能告诉你需要下载某个东西</p> <p><img alt="1705393496704" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705393496704.webp" loading="lazy" class="lazy"></p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> <span class="token function">apt</span> <span class="token parameter variable">-y</span> <span class="token function">install</span> dh-make devscripts
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>再次执行脚本</p> <p><img alt="1705393858017" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705393858017.webp" loading="lazy" class="lazy"></p> <blockquote><p>不知道是不是 bug，这里要敲击 <code>ctrl+C</code> 程序才会继续运行，不然就会一直卡很久才会继续执行。</p></blockquote> <p>安装完后的安装包就是一个以 <code>.deb</code> 结尾的文件</p> <p><img alt="1705393980638" data-src="https://cdn.jsdelivr.net/gh/xiaose-code/Pictures@main/img/1705393980638.webp" loading="lazy" class="lazy"></p> <p>安装这个包可以执行</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> dpkg <span class="token parameter variable">-i</span> com.tq.usbguard_2024.1.16_amd64.deb
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>如果后续要换版本了，不需要这个安装包，想重新打包，需要把 build 目录里的文件全部删除，然后在重新打包</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> <span class="token function">rm</span> <span class="token parameter variable">-fr</span> build/*
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>通过运行 app 程序想看后台，就要跟踪日志文件</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token builtin class-name">cd</span> /tmp
<span class="token function">tail</span> <span class="token parameter variable">-f</span> usbguard-daemon.log
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h1 id="_6-安装过程注意事项"><a href="#_6-安装过程注意事项" class="header-anchor">#</a> 6. 安装过程注意事项</h1> <ol><li>安装之前把所有的u盘拨出</li> <li>插好 USB 接口的鼠标和键盘</li> <li>开始安装</li> <li>首次运行需要等待大约30秒再启动桌面程序</li></ol> <h1 id="_7-项目解读"><a href="#_7-项目解读" class="header-anchor">#</a> 7. 项目解读</h1> <h2 id="_7-1-usb-规则类型"><a href="#_7-1-usb-规则类型" class="header-anchor">#</a> 7.1 USB 规则类型</h2> <p>每个 USB 设备有三种类型的目标规则:</p> <ol><li><strong>allow</strong> – 授权 USB 设备</li> <li><strong>block</strong> – 不授权 USB 设备，但是系统仍然可以使用 lsusb 命令看到（可见）该设备。但是，用户不能使用 USB 设备，因为在系统管理员授权之前，它一直处于被阻止状态。（阻止设备）</li> <li><strong>reject</strong> – 不授权 USB 设备，该设备对系统或用户不可见。USB设备需要再次重新插入才能再次可见。（拒绝该设备）</li></ol> <h2 id="_7-2-了解-etc-usbguard-usbguard-daemon-conf-配置"><a href="#_7-2-了解-etc-usbguard-usbguard-daemon-conf-配置" class="header-anchor">#</a> 7.2 了解 /etc/usbguard/usbguard-daemon.conf 配置</h2> <p><img alt="1706168371028" data-src="https://jsd.cdn.zzko.cn/gh/xiaose-code/Pictures@main/img/1706168371028.webp" loading="lazy" class="lazy"></p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># 我们使用 less 查看文件发现很多东西，难以观察</span>
<span class="token function">sudo</span> <span class="token function">less</span> usbguard-daemon.conf
<span class="token comment"># 所以我们要进行筛选</span>
<span class="token function">sudo</span> <span class="token function">grep</span> <span class="token parameter variable">-vE</span> <span class="token string">'^#|^$'</span> /etc/usbguard/usbguard-daemon.conf
<span class="token comment"># 这个命令主要是在 /etc/usbguard/usbguard-daemon.conf 配置文件中找出并显示所有非注释和非空行。</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p><img alt="1706168542426" data-src="https://jsd.cdn.zzko.cn/gh/xiaose-code/Pictures@main/img/1706168542426.webp" loading="lazy" class="lazy"></p> <ul><li><code>-v</code>：这是 grep 命令的一个选项，会反转搜索结果，也就是说，它会返回所有“不匹配”搜索模式的行。</li> <li><code>-E</code>：这是 grep 命令的一个选项，用于支持扩展的正则表达式。</li> <li><code>'^#|^$'</code>: 这是 grep 要搜索的模式。它是一个正则表达式，用于匹配以 <code>#</code> 开头的行（也就是注解行）或空行。 <code>^</code> 是一种定位符，表示行的开始，<code>|</code> 是 “或”的意思，表示符号前后的任何一个条件满足即可。</li></ul> <table><thead><tr><th>名称</th> <th>解释</th></tr></thead> <tbody><tr><td>RuleFile (规则文件)</td> <td>USBGuard 守护程序将使用该文件加载策略规则集，并写入通过 IPC 接口接收的新规则。</td></tr> <tr><td>ImplicitPolicyTarget (隐式策略目标)</td> <td>如何对待与策略中的任何规则都不匹配的 USB 设备。目标应为允许、阻止或拒绝之一（从系统中逻辑删除设备节点）。</td></tr> <tr><td>PresentDevicePolicy (当前设备策略)</td> <td>如何对待守护进程启动时已经连接的 USB 设备？策略应为允许、阻止、拒绝、保持（保持设备当前的状态）或应用策略（评估每个现有设备的规则集）之一。</td></tr> <tr><td>PresentControllerPolicy (当前控制策略)</td> <td>如何处理守护程序启动时已经连接的 USB 控制器设备。允许、阻止、拒绝、保留或应用策略之一。</td></tr> <tr><td>InsertedDevicePolicy (插入的设备策略)</td> <td>如何对待守护进程启动后已经连接的 USB 设备？阻止、拒绝、应用策略之一。</td></tr> <tr><td>RestoreControllerDeviceState (还原控制器设备状态)</td> <td>USBGuard 守护程序修改控制器设备的某些属性，如新的子设备实例的默认授权状态。使用此设置，您可以控制守护程序在关机时是否尝试将属性值恢复到修改前的状态。</td></tr> <tr><td>DeviceManagerBackend (设备管理器备份)</td> <td>使用哪个设备管理器后端实现。后端应为 uevent（默认）或umockdev 之一。</td></tr> <tr><td>IPCAllowedUsers (IPC 允许的用户)</td> <td>守护程序将接受 IPC 连接的用户名的空格分隔列表。</td></tr> <tr><td>IPCAllowedGroups (IPC 允许的组)</td> <td>守护程序将从其接受 IPC 连接的以空格分隔的组名列表。</td></tr> <tr><td>IPCAccessControlFiles (IPC 访问控制文件)</td> <td>守护程序会将此位置的文件解释为 IPC 访问控制定义文件。详情参见 IPC 访问控制部分。</td></tr> <tr><td>DeviceRulesWithPort (带有端口的设备规则)</td> <td>生成包括“通过端口”属性的设备特定规则。</td></tr> <tr><td>AuditBackend (审计后端)</td> <td>USBGuard 审核事件日志后端。后端值应为 FileAudit 或LinuxAudit 之一。</td></tr> <tr><td>AuditFilePath (审计文件路径)</td> <td>USBGuard 审核事件日志文件路径。如果 AuditBackend 设置为FileAudit，则需要此选项。</td></tr></tbody></table> <h2 id="_7-3-列出-usbguard-守护程序使用的规则集-策略"><a href="#_7-3-列出-usbguard-守护程序使用的规则集-策略" class="header-anchor">#</a> 7.3 列出 USBGuard 守护程序使用的规则集（策略）</h2> <blockquote><p>按照 4.4 部分启动程序后</p> <p>在 /data/tq_usb/usbguard/do_build/.libs 目录下执行后续命令</p></blockquote> <h3 id="_7-3-1-使用以下命令可以列出规则集"><a href="#_7-3-1-使用以下命令可以列出规则集" class="header-anchor">#</a> 7.3.1 使用以下命令可以列出规则集：</h3> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> ./usbguard list-rules
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p><img alt="1706170787626" data-src="https://jsd.cdn.zzko.cn/gh/xiaose-code/Pictures@main/img/1706170787626.webp" loading="lazy" class="lazy"></p> <h3 id="_7-3-2-显示受特定规则影响的所有设备"><a href="#_7-3-2-显示受特定规则影响的所有设备" class="header-anchor">#</a> 7.3.2 显示受特定规则影响的所有设备</h3> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> usbguard list-rules <span class="token parameter variable">-d</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p><img alt="1706170901405" data-src="https://jsd.cdn.zzko.cn/gh/xiaose-code/Pictures@main/img/1706170901405.webp" loading="lazy" class="lazy"></p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> usbguard list-rules --show-devices
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p><img alt="image-20240125162233168" data-src="C:%5CUsers%5Ctq%5CAppData%5CRoaming%5CTypora%5Ctypora-user-images%5Cimage-20240125162233168.png" loading="lazy" class="lazy"></p> <h3 id="_7-3-3-还可以显示具有特定标签的规则"><a href="#_7-3-3-还可以显示具有特定标签的规则" class="header-anchor">#</a> 7.3.3 还可以显示具有特定标签的规则</h3> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> ./usbguard list-rules <span class="token parameter variable">-l</span> <span class="token punctuation">{</span>label_here<span class="token punctuation">}</span>
<span class="token function">sudo</span> ./usbguard list-rules <span class="token parameter variable">--label</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h3 id="_7-3-4-列出-usbguard-守护程序识别的所有-usb-设备"><a href="#_7-3-4-列出-usbguard-守护程序识别的所有-usb-设备" class="header-anchor">#</a> 7.3.4 列出 USBGuard 守护程序识别的所有 USB 设备</h3> <div class="language- line-numbers-mode"><pre class="language-text"><code>sudo ./usbguard list-devices
sudo ./usbguard list-devices -a ## list allowed devices ##
sudo ./usbguard list-devices -b ## list blocked devices ##
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h1 id="_8-项目测试"><a href="#_8-项目测试" class="header-anchor">#</a> 8. 项目测试</h1> <h2 id="_8-1-测试-usb-插入是否默认阻止"><a href="#_8-1-测试-usb-插入是否默认阻止" class="header-anchor">#</a> 8.1 测试 USB 插入是否默认阻止</h2> <p>我将插入我的USB 4G LTE调制解调器，查看它是否被默认阻止并运行 lsusb:</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>lsusb
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>示例输出表明华为USB连接到USB端口（设备009: ID 12d1:157c）并且对系统可见:</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>Bus 004 Device 002: ID 2109:0813 VIA Labs, Inc. USB3.0 Hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 06cb:00bd Synaptics, Inc. 
Bus 001 Device 007: ID 2109:0102 VIA Labs, Inc. Microsoft Ergonomic Keyboard
Bus 001 Device 005: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 003: ID 2109:2813 VIA Labs, Inc. USB2.0 Hub
Bus 001 Device 009: ID 12d1:157c Huawei Technologies Co., Ltd. HUAWEI_MOBILE
Bus 001 Device 006: ID 8087:0029 Intel Corp. 
Bus 001 Device 002: ID 045e:082c Microsoft Corp. Microsoft Ergonomic Keyboard
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><p>但是，该设备被 USBGuard 阻止。您将看到内核消息，指示华为 USB 设备未经授权使用，如下所示:</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> <span class="token function">dmesg</span>
<span class="token function">sudo</span> <span class="token function">dmesg</span> <span class="token operator">|</span> <span class="token function">grep</span> <span class="token parameter variable">-i</span> <span class="token string">'authorized'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>示例输出表明默认情况下 USBGuard 会阻止 USB 调制解调器:</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>[87467.670280] usb 1-2: new high-speed USB device number 8 using xhci_hcd
[87467.820572] usb 1-2: New USB device found, idVendor=12d1, idProduct=157c, bcdDevice= 1.02
[87467.820578] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[87467.820581] usb 1-2: Product: HUAWEI_MOBILE
[87467.820584] usb 1-2: Manufacturer: HUAWEI_MOBILE
[87467.820587] usb 1-2: SerialNumber: 0123456789ABCDEF
[87467.820928] usb 1-2: Device is not authorized for usage
[87477.196260] usb 1-2: USB disconnect, device number 8
[87477.682044] usb 1-2: new high-speed USB device number 9 using xhci_hcd
[87477.831578] usb 1-2: New USB device found, idVendor=12d1, idProduct=157c, bcdDevice= 1.02
[87477.831583] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[87477.831587] usb 1-2: Product: HUAWEI_MOBILE
[87477.831590] usb 1-2: Manufacturer: HUAWEI_MOBILE
[87477.831593] usb 1-2: SerialNumber: 0123456789ABCDEF
[87477.831931] usb 1-2: Device is not authorized for usage
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div><p>我们可以使用以下命令查看被阻止的 USB 设备:</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> ./usbguard list-devices <span class="token parameter variable">-b</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>输出：</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>24: block id 12d1:157c serial &quot;0123456789ABCDEF&quot; name &quot;HUAWEI_MOBILE&quot; hash &quot;8tSOgfYNylANtACo0ysV5qRAx5Ht+geWMd+QOVNcK70=&quot; parent-hash &quot;jEP/6WzviqdJ5VSeTUY8PatCNBKeaREvo2OqdplND/o=&quot; via-port &quot;1-2&quot; with-interface { 08:06:50 02:0e:00 0a:00:02 0a:00:02 08:06:50 } with-connect-type &quot;hotplug&quot;
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>其中数据块的目标策略如下:</p> <ol><li><strong>24</strong> – 设备号</li> <li>**block id 12d1:157c ** – USB 设备 ID</li> <li><strong>serial &quot;0123456789ABCDEF&quot;</strong> – USB 设备序列号</li> <li><strong>name &quot;HUAWEI_MOBILE&quot;</strong> – USB 设备名称</li></ol> <blockquote><p>USB 设备号是动态生成的，在你的 Linux 系统中会有所不同。</p></blockquote> <h2 id="_8-2-暂时允许访问-usb-设备"><a href="#_8-2-暂时允许访问-usb-设备" class="header-anchor">#</a> 8.2 暂时允许访问 USB 设备</h2> <p>默认情况下，我们知道 USBGuard 会阻止连接的USB设备，并将永远被禁止。这意味着基于 USB 的攻击被阻止。但是，如果我想访问合法的 USB 设备呢？尝试以下命令更改数据块策略以允许使用设备块 ID 为12d1:157c 的设备 # 24:</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># sudo ./usbguard allow-device {device_ID}</span>
<span class="token function">sudo</span> ./usbguard allow-device <span class="token number">24</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>还可以使用如下规则:</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> ./usbguard allow-device <span class="token string">'12d1:157c serial &quot;0123456789ABCDEF&quot;'</span>
<span class="token function">sudo</span> ./usbguard allow-device <span class="token string">'12d1:1506 serial &quot;0123456789ABCDEF&quot;'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h2 id="_8-3-永久规则"><a href="#_8-3-永久规则" class="header-anchor">#</a> 8.3 永久规则</h2> <p>我们可以让这个决定永久化。特定于设备的允许规则将附加到当前策略中:</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token comment"># sudo ./usbguard allow-device {device_ID} -p</span>
<span class="token function">sudo</span> ./usbguard allow-device <span class="token number">24</span> <span class="token parameter variable">-p</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>规则代替 ID:</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> usbguard allow-device <span class="token string">'12d1:157c serial &quot;0123456789ABCDEF&quot;'</span> <span class="token parameter variable">-p</span>
<span class="token function">sudo</span> usbguard allow-device <span class="token string">'12d1:1506 serial &quot;0123456789ABCDEF&quot;'</span> <span class="token parameter variable">-p</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>以下是我使用文本编辑器添加到 rules.conf 的规则:</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> /etc/usbguard/rules.conf
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>附加以下内容</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>allow id 12d1:157c serial &quot;0123456789ABCDEF&quot; name &quot;HUAWEI_MOBILE&quot; hash &quot;8tSOgfYNylANtACo0ysV5qRAx5Ht+geWMd+QOVNcK70=&quot; parent-hash &quot;jEP/6WzviqdJ5VSeTUY8PatCNBKeaREvo2OqdplND/o=&quot; via-port &quot;1-2&quot; with-interface { 08:06:50 02:0e:00 0a:00:02 0a:00:02 08:06:50 } with-connect-type &quot;hotplug&quot;
allow id 12d1:1506 serial &quot;&quot; name &quot;HUAWEI_MOBILE&quot; hash &quot;1lr2516yYIsSGGyDZrcgBBNJPlzzthtHbpH1SN5E/VA=&quot; parent-hash &quot;jEP/6WzviqdJ5VSeTUY8PatCNBKeaREvo2OqdplND/o=&quot; via-port &quot;1-2&quot; with-interface { ff:02:12 ff:02:01 ff:02:16 ff:02:16 08:06:50 08:06:50 } with-connect-type &quot;hotplug&quot;
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>保存并关闭文件。重新启动服务:</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>sudo systemctl restart usbguard.service
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h2 id="_8-4-检查"><a href="#_8-4-检查" class="header-anchor">#</a> 8.4 检查</h2> <p>添加规则后，USBGurad 将立即允许 USB 设备访问。现在我可以使用 USB LTE 调制解调器连接到互联网或查看 USD disk:</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>udisksctl status
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><div class="language- line-numbers-mode"><pre class="language-text"><code>MODEL                     REVISION  SERIAL               DEVICE
--------------------------------------------------------------------------
SAMSUNG MZVLB1T0HBLR-000L7 5M2QEXF7  xyzfooooooooo1       nvme0n1 
SAMSUNG MZVLB1T0HBLR-000L7 5M2QEXF7  xyzfooooooooo2       nvme1n1 
HUAWEI TF CARD Storage    2.31      HUAWEI_TF_CARD_Storage-0:0 sda     
HUAWEI Mass Storage       2.31      HUAWEI_Mass_Storage-0:0 sr0   
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p>也不再有错误:</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> <span class="token function">dmesg</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></div></div> <!----> <div class="page-edit"><!----> <!----> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">2024/6/3 14:54:44</span></div></div> <div class="page-nav-wapper"><div class="page-nav-centre-wrap"><a href="/pages/b561cf/" class="page-nav-centre page-nav-centre-prev"><div class="tooltip">高并发内存池</div></a> <a href="/pages/1ab9a6/" class="page-nav-centre page-nav-centre-next"><div class="tooltip">Shell 脚本学习笔记</div></a></div> <div class="page-nav"><p class="inner"><span class="prev">
        ←
        <a href="/pages/b561cf/" class="prev">高并发内存池</a></span> <span class="next"><a href="/pages/1ab9a6/">Shell 脚本学习笔记</a>→
      </span></p></div></div></div> <!----></main></div> <div class="footer"><!----> 
  Theme by
  <a href="https://github.com/xugaoyi/vuepress-theme-vdoing" target="_blank" title="本站主题">Vdoing</a> 
    | Copyright © 2023-2025
    <span>霜晨月</span></div> <div class="buttons"><div title="返回顶部" class="button blur go-to-top iconfont icon-fanhuidingbu" style="display:none;"></div> <div title="去评论" class="button blur go-to-comment iconfont icon-pinglun" style="display:none;"></div> <div title="主题模式" class="button blur theme-mode-but iconfont icon-zhuti"><ul class="select-box" style="display:none;"><li class="iconfont icon-zidong">
          跟随系统
        </li><li class="iconfont icon-rijianmoshi">
          浅色模式
        </li><li class="iconfont icon-yejianmoshi">
          深色模式
        </li><li class="iconfont icon-yuedu">
          阅读模式
        </li></ul></div></div> <!----> <!----> <!----></div><div class="global-ui"><canvas id="vuepress-canvas-cursor"></canvas></div></div>
    <script src="/assets/js/app.67adcfd9.js" defer></script><script src="/assets/js/4.9aaa1650.js" defer></script><script src="/assets/js/1.5474518c.js" defer></script><script src="/assets/js/3.593d14fc.js" defer></script><script src="/assets/js/160.f8624459.js" defer></script>
  </body>
</html>
